import React, { useContext } from "react";
import myContext from "./myContext";

export default function Son() {
  const {state,dispatch} = useContext(myContext);

  function add(){
    dispatch({
      type:"INC",
      payload:3
    })
  }

  return (
    <div>
      <h1>子组件</h1>
      <p>state.count:{state.count}</p>
      <input type="button" value="修改count" onClick={add} />
    </div>
  );
}
